$(function(){
	var admin_id = getCookie('admin_id');
	if(!admin_id){
		window.location.replace('login.html');
	}
	var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, {
        color: '#1AB394'
    });
	//自定义radio样式
	$(".cb-enable").click(function(){
	    var parent = $(this).parents('.onoff');
	    $('.cb-disable',parent).removeClass('selected');
	    $(this).addClass('selected');
	    $('.checkbox',parent).attr('checked', true);
	});
	$(".cb-disable").click(function(){
	    var parent = $(this).parents('.onoff');
	    $('.cb-enable',parent).removeClass('selected');
	    $(this).addClass('selected');
	    $('.checkbox',parent).attr('checked', false);
	});
	//提交表单
   $("#submit").click(function(){
   		 if($("#signupForm").valid()){
          var query = $("#signupForm").serialize();
          ajax_post(ApiUrl + "/goods/category/created","category.html",query);
    	}
   });
   var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules: {
            name: {
                required: true
            }
        },
        messages: {
            name: {
                required: icon+ "请输入分类名称！"
            }
        }
    });
});